<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
    <title></title>
</head>
<body>
<p>
    <button class="js-copy-bob-btn">Set clipboard to BOB</button>
    <button class="js-copy-jane-btn">Set clipboard to JANE</button>
</p>
<p>
    <textarea class="js-test-textarea" cols="50"
              rows="10">Try pasting into here to see what you have on your clipboard:</textarea>
</p>
</body>
<script src="http://apps.bdimg.com/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
    function copyTextToClipboard(text) {
        var textArea = document.createElement("textarea");

        $(textArea).css({
            "position": "fixed",
            "top": "-50px",
            "left": "-50px",
            "width": "2em",
            "height": "2em",
            "padding": 0,
            "border": "none",
            "outline": "none",
            "boxShadow": "none",
            "background": "transparent"
        }).val(text);

        document.body.appendChild(textArea);

        $(textArea).select();

        try {
            var successful = document.execCommand('copy');
            var msg = successful ? 'successful' : 'unsuccessful';
            return true;
        } catch (err) {
            return false;
        }

        document.body.removeChild(textArea);
    }


    /*var copyBobBtn = document.querySelector('.js-copy-bob-btn'),
     copyJaneBtn = document.querySelector('.js-copy-jane-btn');

     copyBobBtn.addEventListener('click', function(event) {
     copyTextToClipboard('Bob');
     });


     copyJaneBtn.addEventListener('click', function(event) {
     copyTextToClipboard('Jane');
     });*/

    $('.js-copy-bob-btn').click(function () {
        copyTextToClipboard("<script>\r\n    (function(i,d,t,o,u,h,c,p){i[t]=i[t]||[],i[t].push(h);i[h] = i[h]||function()\r\n    {return (i[h].q=i[h].q||[]).push(arguments)};i[h].end?i[h](\"track\",h,c,p):(function(s,f) \r\n    {i[h].end=1;s=d.createElement(o);s.src=u;f=d.getElementsByTagName(o)[0];\r\n    f.parentNode.insertBefore(s,f);i[h](\"track\",h,c,p)})()})(window,document, \r\n    \"HyperAnalyticsObject\",\"script\",\"//t.hypers.com.cn/hwt.js?v=1.3\",\"_ha\",{\r\n        UA:\"249\",\r\n        API_URL:\"//t.hypers.com.cn/cgi-bin\",\r\n        SWF_URL:\"//t.hypers.com.cn/hwt.swf#\",\r\n        IFRAME_URL:\"//t.hypers.com.cn/iframe.html\"\r\n     });\r\n<\/script>");
    });

    $('.js-copy-jane-btn').click(function () {
        copyTextToClipboard('Jane');
    });
</script>
</html>
